home *** CD-ROM | disk | FTP | other *** search
/ Perl Multimedia Cyber Classroom / PERL Multimedia Cyber Classroom (Prentice Hall)(1998).ISO / install.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1998-03-31  |  41KB  |  1,173 lines

  1. #!/bin/sh
  2. #
  3. # $Id$
  4. #
  5. # CyberClassroom installation script.
  6. #
  7.  
  8. SCRIPT_NAME="$0"
  9.  
  10. # FUNCTION:     cleanup()
  11. #
  12. # DESCRIPTION: To uninstall any aborted attempted install, cleanup the
  13. # "footprints" of any thing the install did to the user's system, and
  14. # return with the specified error code.
  15. #
  16. # ARGUMENTS: $1 - The error code to exit this script with.
  17. #
  18. # GLOBALS: Assumes $UNINSTALL_LINE1 $UNINSTALL_LINE2 $UNINSTALL_LINE3
  19. # $UNINSTALL_LINE4 are set if need be.
  20. #
  21. # RETURN VALUE: NONE
  22. #
  23. cleanup()
  24. {
  25.   $ECHO
  26.   $ECHO "$SCRIPT_NAME: Installation Aborted, cleaning up..."
  27.   $ECHO
  28.   $UNINSTALL_LINE1
  29.   $UNINSTALL_LINE2
  30.   $UNINSTALL_LINE3
  31.   $UNINSTALL_LINE4
  32.   exit $1
  33. }
  34.  
  35.  
  36. # FUNCTION:     two_value_question()
  37. #
  38. # DESCRIPTION As a question of the user for input that has 2 allowable
  39. # answers.  The first argument is the first allowable answer the user
  40. # can type in and also the default answer if the user just hits the
  41. # enter key. The second argument is the other allowable answer.  The
  42. # comparison is case INDEPENDENT, in other words the answer "YeS" is
  43. # the same as "yes".  Also the first letter of the answer is all that
  44. # is required, however if the user chooses to type the full allowable
  45. # answer then ONLY the first character is checked, in other words
  46. # "Yasdfa" will be interpreted as a valid "YES".
  47. #
  48. # ARGUMENTS:    $1 - first allowable value and also the prompt default
  49. #               $2 - Second allowable value
  50. #
  51. # GLOBALS:      Assumes $L1 $L2 $L3 $L4 $L5 $L6 $L7 are set if need be.
  52. #
  53. # RETURN VALUE: $PROMPT_ANSWER set a the first character of the
  54. # selected prompt.
  55. #
  56. two_value_question()
  57. {
  58.   FIRST_CHAR_OF_ARG1=`$ECHO "$1" | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'` 
  59.   FIRST_CHAR_OF_ARG2=`$ECHO "$2" | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'` 
  60.   QUIT_WHILE=0
  61.   while [ $QUIT_WHILE -eq 0 ]
  62.   do
  63.     $ECHO
  64.     if [ "$L1" != "" ]; then
  65.       $ECHO "$L1"
  66.     fi
  67.     if [ "$L2" != "" ]; then
  68.       $ECHO "$L2"
  69.     fi
  70.     if [ "$L3" != "" ]; then
  71.       $ECHO "$L3"
  72.     fi
  73.     if [ "$L4" != "" ]; then
  74.       $ECHO "$L4"
  75.     fi
  76.     if [ "$L5" != "" ]; then
  77.       $ECHO "$L5"
  78.     fi
  79.     if [ "$L6" != "" ]; then
  80.       $ECHO "$L6"
  81.     fi
  82.     if [ "$L7" != "" ]; then
  83.       $ECHO "$L7"
  84.     fi
  85.     read A_OR_B
  86.     if [ "$A_OR_B" = "" ]; then
  87.       A_OR_B=$1
  88.     fi
  89.     PROMPT_ANSWER=`$ECHO "$A_OR_B" | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'`
  90.     if [ "$PROMPT_ANSWER" != "$FIRST_CHAR_OF_ARG1" -a "$PROMPT_ANSWER" != "$FIRST_CHAR_OF_ARG2" ]; then
  91.       $ECHO
  92.       $ECHO "Please answer with \"$1\" or \"$2\".  Try again."
  93.     else
  94.       QUIT_WHILE=1
  95.     fi
  96.   done
  97.   return 0
  98. }
  99.  
  100. # copy_file_to_file
  101. #
  102. # Takes two arguments as file names for copying.  First argument specifies
  103. # source file, the second specifies the destination file.  Each argument
  104. # may be prepended with absolute or relative path name.  Attempts to
  105. # create any non-existent directories in destination path before copying.
  106. #
  107. # An optional third argument specifies an permissions argument that
  108. # would be passed to a chmod operation on the destination file.
  109.  
  110. # NOTE: Destination is always taken as a file name, not a directory, unless
  111. # a directory with a name matching the destination exists before the call.
  112. #
  113. copy_file_to_file()
  114. {
  115.   $ECHO "Copying $1 to $2 ..."
  116.  
  117.   destdir=`dirname $2`
  118.   if [ $? -eq 0 ] ; then mkdir -p $destdir ; fi
  119.   if [ $? -eq 0 ] ; then cp -p $1 $2 ; fi 
  120.   if [ $? -eq 0 -a "$3" != "" ] ; then chmod $3 $2 ; fi
  121. }
  122.  
  123.  
  124. #
  125. # copy_file_from_list_to_list
  126. #
  127. # Function takes two arguments as lists of source and destination files
  128. # for copying, respectively.  Files in the source list ($1) are copied to
  129. # the corresponding location in the destination list ($2) using the
  130. # copy_file_to_file() function.
  131. #
  132. # An optional third argument is taken as a list of permissions arguments
  133. # that will be applied to the files in the destination list.
  134. #
  135. # Special care should be taken with quoting for forming the lists as single
  136. # arguments.  (This is Bourne shell, after all.)  Naturally, the lists
  137. # should all be of equal length.
  138. #
  139. copy_file_from_list_to_list()
  140. {
  141.     i=1
  142.     for srcfile in $1 ; do
  143.         destfile=`$ECHO "$2" | awk "{ print \\$$i }"`
  144.         destperm=`$ECHO "$3" | awk "{ print \\$$i }"`
  145.         copy_file_to_file $srcfile $destfile $destperm
  146.         status=$?
  147.         if [ $status -ne 0 ] ; then return $status ; fi
  148.         i=`expr $i + 1`
  149.     done
  150. }
  151.  
  152.  
  153. trap '$ECHO;$ECHO "Ctrl-C detected";$ECHO;cleanup 1' 2
  154.  
  155. SCRIPTDIR=`dirname $0`
  156.  
  157. # Get the run-time parameters for this install
  158. if [ -f ./install.ini ] ; then
  159.     . ./install.ini
  160. elif [ -f $SCRIPTDIR/install.ini ] ; then
  161.     . $SCRIPTDIR/install.ini
  162. else
  163.     $ECHO "Error: Could not find install.ini file."
  164.     cleanup 1
  165. fi
  166.  
  167. if [ "$CYBERCLASSROOM_CDROOT" != "" ] ; then
  168.     # set CDROM root explicitly
  169.     CDROM_DIR=$CYBERCLASSROOM_CDROOT
  170. else
  171.     # default the CD root to the directory where the script was found
  172.         cd $SCRIPTDIR
  173.     CDROM_DIR=`/usr/bin/pwd`
  174. fi
  175.  
  176. # The rest of the script runs relative to the root of the CDROM
  177. cd $CDROM_DIR
  178.  
  179. UNINSTALL_LINE1=""
  180. UNINSTALL_LINE2=""
  181. UNINSTALL_LINE3=""
  182. UNINSTALL_LINE4=""
  183.  
  184. printf "%s" "$WELCOME_MSG"
  185.  
  186. # No arguments required for this script
  187. if [ $# -ne 0 ]; then
  188.   $ECHO
  189.   $ECHO "Note: no arguments are required for this installation script."
  190.   $ECHO "The arguments will be ignored."
  191.   $ECHO
  192. fi
  193.  
  194. # Warning message if the current user is not "root"
  195. user=`id | sed 's/^.*(\(.*\)) .*/\1/'`
  196. groupid=`id | sed 's/gid.*(\(.*\))/\1/' | awk '{print $NF}'`
  197. if [ "$user" != "root" ]; then
  198.   L5=""; L6=""; L7=""
  199.   L1="WARNING: This installation script creates files and directories "
  200.   L2="on local mount points.  Unless you have proper file permissions "
  201.   L3="the installation may not proceed properly."
  202.   L4="Continue installation as user \"$user\" ? (yes|no) [no]: \c"
  203.   two_value_question no yes 
  204.   if [ "$PROMPT_ANSWER" != "Y" ]; then
  205.     cleanup 5
  206.   fi
  207.   $ECHO
  208. fi
  209.  
  210.  
  211. INSTALL_JRE=1
  212. JRE_LOCATION=/opt
  213.  
  214.  
  215. L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  216. L1="Do you have the SunSoft JRE installed ? (yes|no) [no]: \c"
  217. two_value_question no yes
  218. if [ "$PROMPT_ANSWER" = "Y" ]; then
  219.   while [ 1 ]
  220.   do
  221.     JRE_LOCATION=/opt
  222.     INSTALL_JRE=0
  223.  
  224.     # Ask for the "jre" in the current path
  225.     $ECHO
  226.     $ECHO "Where is the SunSoft JRE installed ? (ex: \"/opt/apps/jre${CYBERCLASSROOM_JRE_VERSION}\"): \c"
  227.     read RESPONSE
  228.     if [ "$RESPONSE" = "" ]; then
  229.       $ECHO
  230.       $ECHO "You must type a location, such as \"/opt/apps/jre${CYBERCLASSROOM_JRE_VERSION}\".  Try again."
  231.       $ECHO
  232.       continue
  233.     fi
  234.  
  235.     JRE_LOCATION=$RESPONSE
  236.  
  237.     # Check to see if the user is right
  238.     if [ ! -d $JRE_LOCATION ]; then
  239.         $ECHO
  240.         $ECHO "The directory \"$JRE_LOCATION\" does not exist on your system."
  241.         $ECHO "Please try another path."
  242.         $ECHO
  243.         continue
  244.     fi
  245.  
  246.     # OK Now we have the location
  247.     JRE_EXECUTABLE=$JRE_LOCATION/bin/jre
  248.  
  249.     # Check for the JRE and run it, make sure it's the version
  250.     # CyberClassroom needs or a version
  251.     # that is later.
  252.     if [ ! -f $JRE_EXECUTABLE ]; then
  253.       TMP_JRE_LOCATION=$JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}
  254.       TMP_JRE_EXECUTABLE=$TMP_JRE_LOCATION/bin/jre
  255.       if [ ! -f $TMP_JRE_EXECUTABLE ]; then
  256.         L5=""; L6=""; L7=""
  257.         L1="The executable \"$TMP_JRE_EXECUTABLE\" does not exist "
  258.         L2="Maybe there is a damaged installation of a previous JRE."
  259.         L3="Do you wish to reinstall the JRE in the directory"
  260.         L4="\"$JRE_LOCATION\" ? (yes/no) [yes]: \c"
  261.         two_value_question yes no
  262.         if [ "$PROMPT_ANSWER" = "Y" ]; then
  263.           INSTALL_JRE=1
  264.           break
  265.         else
  266.           L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  267.           L1="Choose another location? (yes/no) [yes]: \c"
  268.           two_value_question yes no
  269.           if [ "$PROMPT_ANSWER" = "Y" ]; then
  270.             continue
  271.           else
  272.             $ECHO
  273.             $ECHO "$0: ERROR: A possibly damaged installation of the JRE was detected"
  274.             $ECHO "in the directory \"$JRE_LOCATION\"."
  275.             $ECHO "Please correct this problem and run this installation again."
  276.             cleanup 15
  277.           fi
  278.         fi
  279.       else
  280.         JRE_LOCATION=$TMP_JRE_LOCATION
  281.         JRE_EXECUTABLE=$TMP_JRE_EXECUTABLE
  282.       fi
  283.     fi
  284.  
  285.     CURRENT_JRE=`$JRE_EXECUTABLE -help 2>&1 | grep -i Version | awk '{print $NF}'`
  286.     if [ `$ECHO "$CURRENT_JRE" | awk -F. '{print $1$2$3$4}'` -ne `$ECHO "$CYBERCLASSROOM_JRE_VERSION" | awk -F. '{print $1$2$3$4}'` ]; then
  287.       L7=""
  288.       L1="The JRE executable [$CURRENT_JRE] on your system"
  289.       L2="is not the version used by the CyberClassroom JRE "
  290.       L3="[jre version \"$CYBERCLASSROOM_JRE_VERSION\"]."
  291.       L4="If you are using a version older than this,"
  292.       L5="it is recommended you install the CyberClassroom JRE version as well."
  293.       L6="Continue and use existing JRE  ? (yes/no) [no]: \c"
  294.       two_value_question no yes
  295.       if [ "$PROMPT_ANSWER" = "Y" ]; then
  296.         INSTALL_JRE=0
  297.       else
  298.         INSTALL_JRE=1
  299.       fi
  300.       break
  301.     else
  302.       break
  303.     fi
  304.  
  305.   done
  306.  
  307. fi
  308.  
  309. # If the JRE needs installing do it now
  310.  
  311. while [ 1 ]
  312. do
  313. if [ $INSTALL_JRE -eq 1 ]; then
  314.   $ECHO
  315.   $ECHO "You are about to install the SunSoft JRE version $CYBERCLASSROOM_JRE_VERSION."
  316.   $ECHO "Please conform to all licensing agreements."
  317.   $ECHO "NOTE: The installer will create a directory named (jre${CYBERCLASSROOM_JRE_VERSION})"
  318.   $ECHO "      inside the directory you specify.  For example, if you specify \"/opt\" in"
  319.   $ECHO "      response to the prompt below, the JRE will be installed in directory "
  320.   $ECHO "      \"/opt/jre${CYBERCLASSROOM_JRE_VERSION}\""
  321.   $ECHO "Where do we install the SunSoft JRE (full directory path) ? [$JRE_LOCATION]: \c"
  322.   read RESPONSE
  323.   if [ "$RESPONSE" != "" ]; then
  324.     JRE_LOCATION=$RESPONSE
  325.   fi
  326.   L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  327.   L1="Install SunSoft JRE in directory ($JRE_LOCATION) creating if necessary ? (yes/no) [yes]: \c  "
  328.   two_value_question yes no
  329.   if [ "$PROMPT_ANSWER" = "N" ]; then
  330.     L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  331.     L1="Choose another location ? (yes/no) [yes]: \c"
  332.     two_value_question yes no
  333.     if [ "$PROMPT_ANSWER" = "Y" ]; then
  334.       continue
  335.     else
  336.       cleanup 20
  337.     fi
  338.   fi
  339.  
  340.   # Check if destination directory exists, remove the whole thing!!!
  341.   if [ -d $JRE_LOCATION ]; then
  342.     if [ -d $JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION} ]; then
  343.       L4=""; L5=""; L6=""; L7=""
  344.       L1="The JRE Directory \"$JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}\" already exists."
  345.       L2="To avoid any possible problems, this directory should be cleaned before installation."
  346.       L3="Remove all files in $JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}? (yes/no) [yes]: \c"
  347.       two_value_question yes no
  348.       if [ "$PROMPT_ANSWER" = "Y" ]; then
  349.  
  350.         rm -rf $JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}
  351.         if [ $? -ne 0 ]; then
  352.           $ECHO
  353.           $ECHO "$0: ERROR: following system command failed:"
  354.           $ECHO "\"rm -rf $JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}\""
  355.           $ECHO "Unable to remove an old installation of the JRE."
  356.           $ECHO
  357.           cleanup 25
  358.         fi
  359.  
  360.       fi
  361.     fi
  362.  
  363.     UNINSTALL_LINE1="rm -rf $JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}"
  364.  
  365.   else
  366.  
  367.     mkdir -p $JRE_LOCATION
  368.     if [ $? -ne 0 ]; then
  369.       $ECHO
  370.       $ECHO "$0: ERROR: following system command failed:"
  371.       $ECHO "\"mkdir -p $JRE_LOCATION\""
  372.       $ECHO "Unable to create a new directory for the JRE."
  373.       $ECHO
  374.       cleanup 30
  375.     fi
  376.  
  377.     UNINSTALL_LINE1="rm -rf $JRE_LOCATION"
  378.  
  379.   fi
  380.  
  381.   cp ./$SOLARIS_JRE_RUNTIME $JRE_LOCATION
  382.   if [ $? -ne 0 ]; then
  383.     $ECHO
  384.     $ECHO "$0: ERROR: following system command failed:"
  385.     $ECHO "\"cp  ./$SOLARIS_JRE_RUNTIME $JRE_LOCATION\""
  386.     $ECHO "Unable to install JRE."
  387.     $ECHO
  388.     cleanup 35
  389.   fi
  390.  
  391.   chmod a+x $JRE_LOCATION/$SOLARIS_JRE_RUNTIME
  392.   if [ $? -ne 0 ]; then
  393.     $ECHO
  394.     $ECHO "$0: ERROR: following system command failed:"
  395.     $ECHO "\"chmod a+x $JRE_LOCATION/$SOLARIS_JRE_RUNTIME\""
  396.     $ECHO "Unable to install JRE."
  397.     $ECHO
  398.     cleanup 40
  399.   fi
  400.  
  401.   (cd $JRE_LOCATION;./$SOLARIS_JRE_RUNTIME)
  402.   if [ $? -ne 0 ]; then
  403.     $ECHO
  404.     $ECHO "$0: ERROR: following system command failed:"
  405.     $ECHO "\"(cd $JRE_LOCATION;./$SOLARIS_JRE_RUNTIME)\""
  406.     $ECHO "Unable to install JRE."
  407.     $ECHO
  408.     cleanup 45
  409.   fi
  410.  
  411.   # Remove the local copy of the JRE Runtime
  412.   rm -rf $JRE_LOCATION/$SOLARIS_JRE_RUNTIME
  413.   if [ $? -ne 0 ]; then
  414.     $ECHO
  415.     $ECHO "$0: ERROR: following system command failed:"
  416.     $ECHO "\"rm -rf $JRE_LOCATION/$SOLARIS_JRE_RUNTIME\""
  417.     $ECHO "Unable to install JRE."
  418.     $ECHO
  419.     cleanup 50
  420.   fi
  421.  
  422.   JRE_LOCATION=$JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}
  423.  
  424. fi
  425. break
  426. done
  427.  
  428. # Now install the actuall CyberClassroom Viewer and accompanying book.
  429. # Ask if the want to install it locally or leave it on the CDROM.         
  430. # Check for previous CyberClassroom and remove if older.
  431. # Check to see if there is space to install.
  432. # Finally, write the commands necessary to do the unistallation script.
  433.  
  434. $ECHO
  435. $ECHO "You are about to proceed with the Cyber Classroom installation."
  436. $ECHO
  437. $ECHO "\"Compact\" Installation requires approximately $CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_MB_FOR_COMPACT MB of disk space."
  438. $ECHO "All of the data files are installed on your local hard disk, EXCEPT"
  439. $ECHO "the audio files, which remain on the CD-ROM.  Links to these large"
  440. $ECHO "files are created on your hard drive.  This means you MUST have the "
  441. $ECHO "CD-ROM in your CD-ROM drive in order to run the Cyber Classroom."
  442. $ECHO
  443. $ECHO "\"Full\" Installation requires approximately $CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_MB_FOR_FULL MB of disk space."
  444. $ECHO "All of the data files are installed your local hard disk, INCLUDING"
  445. $ECHO "the audio files.  You do not need the CD-ROM in your CD-ROM drive"
  446. $ECHO "to run the Cyber Classroom."
  447. $ECHO
  448.  
  449. L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  450. L1="Which installation option do you choose ? (Compact/Full) [Compact]: \c"
  451. two_value_question Compact Full
  452. if [ "$PROMPT_ANSWER" = "C" ]; then
  453.   INSTALLATION_OPTION="Compact"
  454. else
  455.   INSTALLATION_OPTION="Full"
  456. fi
  457.  
  458.  
  459. # OK installation type determined lets check disk space 
  460.  
  461. if [ "$INSTALLATION_OPTION" = "Compact" ]; then
  462.   CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K=$CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K_FOR_COMPACT
  463. else
  464.   CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K=$CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K_FOR_FULL
  465. fi
  466.  
  467. $ECHO
  468. $ECHO "Installation Mode \"$INSTALLATION_OPTION\" Chosen....."
  469. $ECHO
  470.  
  471.  
  472. while [ 1 ]
  473. do
  474.   CYBERCLASSROOM_LOCATION=/opt/CyberClassroom
  475.   $ECHO
  476.   $ECHO "Note: If you have done previous installation of any CyberClassroom"
  477.   $ECHO "product, it is suggested you use the same directory as before."
  478.   $ECHO "This will eliminate duplicate copies of the CyberClassroom Viewer"
  479.   $ECHO "Where do we install the CyberClassroom (full directory path) ? [$CYBERCLASSROOM_LOCATION]: \c"
  480.  
  481.   read RESPONSE
  482.  
  483.   # if it's not null then don't use the default prompt answer
  484.   if [ "$RESPONSE" != "" ]; then
  485.     CYBERCLASSROOM_LOCATION=$RESPONSE
  486.   fi  
  487.  
  488.   # Check to see if the main directory exists
  489.   if [ ! -d $CYBERCLASSROOM_LOCATION ]; then
  490.  
  491.     L4=""; L5=""; L6=""; L7=""
  492.     L1="The directory you have chosen"
  493.     L2="\"$CYBERCLASSROOM_LOCATION\""
  494.     L3="does not exist. Create Directory Now ? (yes/no) [yes]: \c"
  495.     two_value_question yes no
  496.     if [ "$PROMPT_ANSWER" = "Y" ]; then
  497.  
  498.       mkdir -p $CYBERCLASSROOM_LOCATION
  499.       if [ $? -ne 0 ]; then
  500.         $ECHO
  501.         $ECHO "$0: ERROR: following system command failed:"
  502.         $ECHO "\"mkdir -p $CYBERCLASSROOM_LOCATION\""
  503.         $ECHO "Unable to create directory <$CYBERCLASSROOM_LOCATION>."
  504.         $ECHO
  505.         DIR_OK=0
  506.       else
  507.         UNINSTALL_LINE4="rm -rf $CYBERCLASSROOM_LOCATION"
  508.         DIR_OK=1
  509.       fi
  510.     # Prompt answer as no
  511.     else 
  512.       DIR_OK=0
  513.     fi
  514.  
  515.     if [ $DIR_OK -eq 0 ]; then
  516.       L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
  517.       L1="Choose another location? (yes/no) [yes]: \c"
  518.       two_value_question yes no
  519.       if [ "$PROMPT_ANSWER" = "Y" ]; then
  520.         continue
  521.       else
  522.         cleanup 55
  523.       fi
  524.     fi
  525.   fi
  526.  
  527.   # Check for required space in the selected CyberClassroom directory.  We do this by finding what
  528.   # partition this directory is mounted on.  (Ex. /export/home/generic/CyberClassroom is on the /export/home
  529.   # partition.
  530.  
  531.   $ECHO
  532.   $ECHO "Checking Disk Space Requirements....."
  533.   $ECHO
  534.   CURRENT_LOCATION_K=`df -k $CYBERCLASSROOM_LOCATION | tail -1 | awk '{print $4}'`
  535.   if [  $CURRENT_LOCATION_K -le $CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K ]; then
  536.     L5=""; L6=""; L7=""
  537.     L1="WARNING: The directory you selected for $INSTALLATION_OPTION CyberClassroom installation "
  538.     L2="\"$CYBERCLASSROOM_LOCATION\" only has ${CURRENT_LOCATION_K}K of available space."
  539.     L3="in its partition. The CyberClassroom product requires ${CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K}K of space."
  540.     L4="Select Another Location? (yes/no) [yes]: \c"
  541.     two_value_question yes no
  542.     if [ "$PROMPT_ANSWER" = "N" ]; then
  543.       cleanup 60
  544.     fi
  545.   else 
  546.     # Space test succeeded
  547.     break
  548.   fi
  549.  
  550. done
  551.  
  552. # Do check for a Previous CyberClassroom Viewer and ask (or recommend) to replace it if is
  553. # identified as an old version
  554.  
  555. INSTALL_NEW_VIEWING_ENGINE=0
  556. if [ -d $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR ]; then
  557.  
  558.   CURRENT_CYBERCLASSROOM_VERSION=`$JRE_LOCATION/bin/jre -cp $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/gsl.jar gsl.gui.Classroom -version`
  559.   if [ $? -ne 0 ]; then
  560.     $ECHO
  561.     $ECHO "$0: ERROR: following script command \"$JRE_LOCATION/bin/jre -cp "
  562.     $ECHO "$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/gsl.jar gsl.gui.Classroom"
  563.     $ECHO " -version\" failed."
  564.     $ECHO "Unable to determine an existing CyberClassroom Viewer version number."
  565.     $ECHO "A new Viewer will be installed to correct the damaged installation."
  566.     $ECHO
  567.     INSTALL_NEW_VIEWING_ENGINE=1
  568.   else
  569.     if [ `$ECHO "$CURRENT_CYBERCLASSROOM_VERSION" | awk -F. '{print $1$2$3$4}'` -lt `$ECHO "$CYBERCLASSROOM_VIEWER_VERSION" | awk -F. '{print $1$2$3$4}'` ]; then
  570.       L6=""; L7=""
  571.       L1="Note: The installation script has determined that you already have a previous installation of"
  572.       L2="the CyberClassroom Viewing Engine (i.e. the "$CYBERCLASSROOM_VIEWER_DIR" directory) and determined that its version"
  573.       L3="($CURRENT_CYBERCLASSROOM_VERSION) is older than the one being installed now ($CYBERCLASSROOM_VIEWER_VERSION)."
  574.       L4="It is STRONGLY recommended that you install the updated version of this viewing engine."
  575.       L5="Shall we proceed and install the new CyberClassroom Viewing Engine ? (yes/no) [yes]: \c"
  576.       two_value_question yes no
  577.       if [ "$PROMPT_ANSWER" = "Y" ]; then
  578.         INSTALL_NEW_VIEWING_ENGINE=1
  579.       fi
  580.     fi
  581.   fi
  582. else
  583.   INSTALL_NEW_VIEWING_ENGINE=1
  584. fi
  585.  
  586. if [ $INSTALL_NEW_VIEWING_ENGINE -eq 1 ]; then
  587.  
  588.   if [ -d $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR ]; then
  589.     rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR
  590.     if [ $? -ne 0 ]; then
  591.       $ECHO
  592.       $ECHO "$0: ERROR: following system command failed:"
  593.       $ECHO "\"rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR\""
  594.       $ECHO "Unable to remove an old CyberClassroom Viewing Engine."
  595.       $ECHO
  596.       cleanup 65
  597.     fi
  598.   fi
  599.  
  600.   $ECHO
  601.   $ECHO "Copying Viewer Files....."
  602.   $ECHO
  603.  
  604.   cp -R $CYBERCLASSROOM_VIEWER_DIR $CYBERCLASSROOM_LOCATION
  605.   if [ $? -ne 0 ]; then
  606.     $ECHO
  607.     $ECHO "$0: ERROR: following system command failed:"
  608.     $ECHO "\"cp -R $CYBERCLASSROOM_VIEWER_DIR $CYBERCLASSROOM_LOCATION\""
  609.     $ECHO "Unable to install an new CyberClassroom Viewing Engine."
  610.     $ECHO
  611.     cleanup 70
  612.   fi
  613.  
  614.   # Set at least write permission so that this directory can be
  615.   # removed if the uninstallation is run.
  616.  
  617.   chmod -R u+w $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR
  618.   if [ $? -ne 0 ]; then
  619.     $ECHO
  620.     $ECHO "$0: ERROR: following system command failed:"
  621.     $ECHO "\"chmod -R u+w $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR\""
  622.     $ECHO "Unable to install an new CyberClassroom Viewing Engine."
  623.     $ECHO
  624.     cleanup 72
  625.   fi
  626.  
  627.  
  628.   UNINSTALL_LINE3="rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR"
  629.  
  630. fi
  631.  
  632.  
  633.  
  634. # Now, install the book checking for "Compact" or "Full" Installation
  635. # If already there, then remove it first and replace with a new one
  636.  
  637. INSTALL_NEW_BOOK_DIR=0
  638. if [ -d $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR ]; then
  639.   L5=""; L6=""; L7=""
  640.   L1="Note: The installation script has determined that you already"
  641.   L2="have a previous installation of the CyberClassroom Book"
  642.   L3="directory \"$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR\"."
  643.   L4="Should we reinstall over this directory (answer \"no\" to abort this script) ? (yes/no) [yes]: \c"
  644.   two_value_question yes no
  645.   if [ "$PROMPT_ANSWER" = "Y" ]; then
  646.     INSTALL_NEW_BOOK_DIR=1
  647.   else
  648.     cleanup 73
  649.   fi
  650. else
  651.   INSTALL_NEW_BOOK_DIR=1
  652. fi
  653.  
  654. if [ $INSTALL_NEW_BOOK_DIR -eq 1 ]; then
  655.  
  656.   if [ -d $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR ]; then
  657.     rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR
  658.     if [ $? -ne 0 ]; then
  659.       $ECHO
  660.       $ECHO "$0: ERROR: following system command failed:"
  661.       $ECHO "\"rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR\""
  662.       $ECHO "Unable to remove an old installation of this CyberClassroom book."
  663.       $ECHO
  664.       cleanup 75
  665.     fi
  666.   fi
  667.  
  668.   $ECHO
  669.   $ECHO "Copying Book Files....."
  670.   $ECHO
  671.  
  672.   # First copy the contents of the book directory without the jar
  673.   # files, zip files and answers directory.  Using cpio method creates
  674.   # the main directory as well as the sub directories if necessary.
  675.   # The users custom umask could subtract write permission from us, therefor
  676.   # try and add if for the tar command below, then restore it.
  677.  
  678.   old_mask=`umask`
  679.   umask 0000
  680.   tar cvf - `ls -d $CYBERCLASSROOM_BOOK_DIR/* | egrep -v '\.zip$|\.jar$|\/answers$'` | ( cd $CYBERCLASSROOM_LOCATION; tar xvf - )
  681.   if [ $? -ne 0 ]; then
  682.      $ECHO
  683.      $ECHO "$0: ERROR: following system command failed:"
  684.      $ECHO "\"tar cvf - \`ls -d $CYBERCLASSROOM_BOOK_DIR/* | egrep -v '\.zip$|\.jar$|\/answers$'\` | ( cd $CYBERCLASSROOM_LOCATION; tar xvf - )\""
  685.      $ECHO "Unable to install the CyberClassroom book."
  686.      $ECHO
  687.      cleanup 76
  688.   fi
  689.   umask $old_mask
  690.  
  691.  
  692.   # First create the directory tree and set permissions on it
  693.   #find $CYBERCLASSROOM_BOOK_DIR -type d-print | cpio -pmd $CYBERCLASSROOM_LOCATION
  694.   #status=$?
  695.   #if [ $status -eq 0 ] ; then chmod -R u+rw $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR ; fi
  696.   #chmod -R u+rw $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR
  697.   #if [ $? -ne 0 ]; then
  698.   #  $ECHO
  699.   #  $ECHO "$0: ERROR: Failed change permission on book files in $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR"
  700.   #  $ECHO "Unable to install the CyberClassroom book."
  701.   #  $ECHO
  702.   #  cleanup 80
  703.   #fi
  704.   #status=$?
  705.  
  706.   # Now, if that was OK, copy file files
  707.   #if [ $status -eq 0 ]; then find $CYBERCLASSROOM_BOOK_DIR -print | egrep -v '\.zip$|\.jar$|\/answers$' | cpio -pmd $CYBERCLASSROOM_LOCATION ; fi
  708.   #status=$?
  709.   #if [ $status -ne 0 ]; then
  710.   #  $ECHO
  711.   #  $ECHO "$0: ERROR: Failed copying book files to $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR"
  712.   #  $ECHO "Unable to install the CyberClassroom book."
  713.   #  $ECHO
  714.   #   cleanup 80
  715.   #fi
  716.  
  717.   # Now copy any "extra" files in the explicit copy lists
  718.   if [ "$EXPLICIT_COPY_SOURCE_LIST" != "" ] ; then
  719.     full_dest_list=""
  720.     for x in $EXPLICIT_COPY_DEST_LIST ; do
  721.       full_dest_list="$full_dest_list $CYBERCLASSROOM_LOCATION/$x"
  722.     done
  723.  
  724.     copy_file_from_list_to_list "$EXPLICIT_COPY_SOURCE_LIST" "$full_dest_list" "$EXPLICIT_COPY_DEST_PERMS"
  725.     if [ $? -ne 0 ]; then
  726.        $ECHO
  727.        $ECHO "ERROR: Failed to copy files: $EXPLICIT_SOURCE_LIST"
  728.        $ECHO "Unable to install the CyberClassroom book file ($CYBERCLASSROOM_BOOK_FILE)."
  729.        $ECHO
  730.        cleanup 82
  731.     fi
  732.   fi
  733.  
  734.   UNINSTALL_LINE2="$UNINSTALL_LINE2 rm -rf $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR"
  735.  
  736.   # For a "Full" installation, copy the jar and zip files along with the answers directory.
  737.   if [ "$INSTALLATION_OPTION" = "Full" ]; then
  738.     tar cvf - `ls -d $CYBERCLASSROOM_BOOK_DIR/*.jar $CYBERCLASSROOM_BOOK_DIR/*.zip $CYBERCLASSROOM_BOOK_DIR/answers` | ( cd $CYBERCLASSROOM_LOCATION; tar xvf - )
  739.     if [ $? -ne 0 ]; then
  740.        $ECHO
  741.        $ECHO "$0: ERROR: following system command failed:"
  742.        $ECHO "\"tar cvf - \`ls $CYBERCLASSROOM_BOOK_DIR/*.jar\` | ( cd $CYBERCLASSROOM_LOCATION; tar xvf - )\""
  743.        $ECHO "Unable to install the CyberClassroom book file ($CYBERCLASSROOM_BOOK_FILE)."
  744.        $ECHO
  745.        cleanup 83
  746.     fi
  747.   fi
  748.  
  749.   # tar maintains the user id and group id of the tar creator,
  750.   # therefore, change them both to the user whose doing the install.
  751.  
  752.   chown -R $user $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR
  753.   if [ $? -ne 0 ]; then
  754.     $ECHO
  755.     $ECHO "$0: ERROR: following system command failed:"
  756.     $ECHO "chown -R $user $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR"
  757.     $ECHO "Unable to install the CyberClassroom book."
  758.     $ECHO
  759.     cleanup 84
  760.   fi
  761.  
  762.   chgrp -R $groupid $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR
  763.   if [ $? -ne 0 ]; then
  764.     $ECHO
  765.     $ECHO "$0: ERROR: following system command failed:"
  766.     $ECHO "chgrp -R $groupid $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR"
  767.     $ECHO "Unable to install the CyberClassroom book."
  768.     $ECHO
  769.     cleanup 85
  770.   fi
  771.  
  772.  
  773.   # Remember, if root installs to a system directory and any other user run from there, then 
  774.   # were gonna need write permission on the book directory for "others" because thats where the
  775.   # "go.sh" file gets extracted and written.  Just to be safe, lets give the book
  776.   # directory 755 permission.
  777.  
  778.   chmod -R 755 $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR
  779.   if [ $? -ne 0 ]; then
  780.     $ECHO
  781.     $ECHO "$0: ERROR: following system command failed:"
  782.     $ECHO "\"chmod -R 755 $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR\""
  783.     $ECHO "Unable to install the CyberClassroom book."
  784.     $ECHO
  785.     cleanup 86
  786.   fi
  787.  
  788.   # *******************************************
  789.   # MEGA KLUDGE!!!!!!!!!!!!!
  790.   # *******************************************
  791.   # To execute the programs, for some reason the viewer extracts
  792.   # the shell files and executable file into the MAIN CyberClassroom (/opt/CyberClassroom)
  793.   # directory instead of the CyberClassroom book directory.  Therefore,
  794.   # we need global write permission on the CyberClassroom directory in the situation
  795.   # where root does the install (like in directory /opt/CyberClassroom) and a user
  796.   # runs it from there.
  797.   chmod a+w $CYBERCLASSROOM_LOCATION
  798.   if [ $? -ne 0 ]; then
  799.     $ECHO
  800.     $ECHO "$0: ERROR: following system command failed:"
  801.     $ECHO "\"chmod 755 $CYBERCLASSROOM_LOCATION\""
  802.     $ECHO "Unable to install the CyberClassroom book."
  803.     $ECHO
  804.     cleanup 99
  805.   fi
  806.  
  807.   $ECHO
  808.   $ECHO "Making Setup Files....."
  809.   $ECHO
  810.  
  811.   # Make sure the "$CYBERCLASSROOM_BOOK_DIR/webdb.ini" file is
  812.   # properly initialized by recreating it here with its default
  813.   # values.  Also make sure its writtable by any user.
  814.   #
  815.   rm -f  $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_INITIALIZATION_FILE
  816.   cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_INITIALIZATION_FILE
  817. 0
  818. 0
  819. 0
  820. true
  821. EOF
  822.  
  823.   if [ $? -ne 0 ]; then
  824.     $ECHO
  825.     $ECHO "$0: ERROR: following system command failed:"
  826.     $ECHO "\"cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_INITIALIZATION_FILE\""
  827.     $ECHO "Unable to create the default setup file ($CYBERCLASSROOM_INITIALIZATION_FILE) for the CyberClassroom book."
  828.     $ECHO
  829.     cleanup 100
  830.   fi
  831.  
  832.   chmod a+w $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_INITIALIZATION_FILE
  833.   if [ $? -ne 0 ]; then
  834.     $ECHO
  835.     $ECHO "$0: ERROR: following system command failed:"
  836.     $ECHO "\"chmod a+w $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_INITIALIZATION_FILE\""
  837.     $ECHO "Unable to change permissions on the default setup file for the CyberClassroom book."
  838.     $ECHO
  839.     cleanup 105
  840.   fi
  841.  
  842.   # Create the "$CYBERCLASSROOM_HTML_FILE" file based on the
  843.   # installation option.
  844.  
  845.   rm -f  $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE
  846.   cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE
  847. <hr>
  848. <applet code=gsl.gui.Starter width=621 height=421>
  849. EOF
  850.   if [ $? -ne 0 ]; then
  851.     $ECHO
  852.     $ECHO "$0: ERROR: following system command failed:"
  853.     $ECHO "\"cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE\""
  854.     $ECHO "Unable to create main html file for the CyberClassroom book."
  855.     $ECHO
  856.     cleanup 110
  857.   fi
  858.  
  859.   if [ "$INSTALLATION_OPTION" = "Full" ]; then
  860.     cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE
  861. <param name=gmlarch value="$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_FILE;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/figures.jar;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/intro.zip;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/examples.jar;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/code.jar;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/bckgrnds.jar;$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/audio.zip">
  862. EOF
  863.     if [ $? -ne 0 ]; then
  864.       $ECHO
  865.       $ECHO "$0: ERROR: following system command failed:"
  866.       $ECHO "\"cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE\""
  867.       $ECHO "Unable to create main html file for the CyberClassroom book."
  868.       $ECHO
  869.       cleanup 111
  870.     fi
  871.   else
  872.     cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE
  873. <param name=gmlarch value="$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_FILE;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/figures.jar;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/intro.zip;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/examples.jar;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/code.jar;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/bckgrnds.jar;$CDROM_DIR/$CYBERCLASSROOM_BOOK_DIR/audio.zip">
  874. EOF
  875.     if [ $? -ne 0 ]; then
  876.       $ECHO
  877.       $ECHO "$0: ERROR: following system command failed:"
  878.       $ECHO "\"cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE\""
  879.       $ECHO "Unable to create main html file for the CyberClassroom book."
  880.       $ECHO
  881.       cleanup 112
  882.     fi
  883.   fi
  884.  
  885.   cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE
  886. <param name=book value="$CYBERCLASSROOM_BOOK_NAME.gmlb">
  887. <param name=lastindex value=17>
  888. <param name=fontsize value="16">
  889. <param name=starter value="gsl.gui.perl.PerlStarter">
  890. <param name=aliases value="jarexe=xterm -e /bin/sh ">
  891. </applet>
  892. <hr>
  893. EOF
  894.   if [ $? -ne 0 ]; then
  895.     $ECHO
  896.     $ECHO "$0: ERROR: following system command failed:"
  897.     $ECHO "\"cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE\""
  898.     $ECHO "Unable to create main html file for the CyberClassroom book."
  899.     $ECHO
  900.     cleanup 113
  901.   fi
  902.  
  903.  
  904. fi # if [ $INSTALL_NEW_BOOK_DIR -eq 1 ]
  905.  
  906. # Now, build the script which will launch the CyberClassroom product
  907. # for the user Again, make sure that its executable by every user.
  908.  
  909. cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_SCRIPT
  910. PATH=$JRE_LOCATION/bin:/usr/openwin/bin:$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR:$PATH
  911. export PATH
  912. jre -cp $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/gsl.jar:$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/ism.jar:$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/ui.jar:$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_VIEWER_DIR/search.jar gsl.gui.Classroom file://$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_HTML_FILE &
  913. EOF
  914. if [ $? -ne 0 ]; then
  915.   $ECHO
  916.   $ECHO "$0: ERROR: following system command failed:"
  917.   $ECHO "\"cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_SCRIPT\""
  918.   $ECHO "Unable to create startup script for the CyberClassroom book."
  919.   $ECHO
  920.   cleanup 120
  921. fi
  922.  
  923. chmod a+x $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_SCRIPT
  924. if [ $? -ne 0 ]; then
  925.   $ECHO
  926.   $ECHO "$0: ERROR: following system command failed:"
  927.   $ECHO "\"chmod a+x $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_SCRIPT\""
  928.   $ECHO "Unable to create startup script for the CyberClassroom book."
  929.   $ECHO
  930.   cleanup 125
  931. fi
  932.  
  933. # Build a script for uninstallation operation
  934.  
  935. cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  936. #!/bin/sh
  937. QUIT_WHILE=0
  938. while [ \$QUIT_WHILE -eq 0 ]
  939. do
  940.   $ECHO_FOR_UNINSTALL
  941.   $ECHO_FOR_UNINSTALL "WARNING: This Prentice Hall CyberClassroom uninstallation script"
  942.   $ECHO_FOR_UNINSTALL "will run several system remove commands with verification (assuming you"
  943.   $ECHO_FOR_UNINSTALL "have file permissions to do so of course):"
  944.   $ECHO_FOR_UNINSTALL
  945.   $ECHO_FOR_UNINSTALL "It is recommended that you move this script to a location (such as /tmp) other"
  946.   $ECHO_FOR_UNINSTALL "than a CyberClassroom related directory.  By default, this script is installed"
  947.   $ECHO_FOR_UNINSTALL "in the main CyberClassroom directory.  Since this uninstallation script gives"
  948.   $ECHO_FOR_UNINSTALL "you the option to remove the main CyberClassroom directory in which it resides,"
  949.   $ECHO_FOR_UNINSTALL "you must move this script from there in order for the system remove command to succeed."
  950.   $ECHO_FOR_UNINSTALL
  951.   $ECHO_FOR_UNINSTALL "Do you want to continue ? (yes|no) [no]: \c"
  952.   read YES_OR_NO
  953.   if [ "\$YES_OR_NO" = "" ]; then
  954.     YES_OR_NO="no"
  955.   fi
  956.   PROMPT_ANSWER=\`$ECHO_FOR_UNINSTALL "\$YES_OR_NO" | tr "[:lower:]" "[:upper:]" | awk '{print substr(\$1,1,1)}'\`
  957.   if [ "\$PROMPT_ANSWER" != "Y" -a "\$PROMPT_ANSWER" != "N" ]; then
  958.     $ECHO_FOR_UNINSTALL 
  959.     $ECHO_FOR_UNINSTALL "Please answer with \\"yes\\" or \\"no\\".  Try again."
  960.   else
  961.     QUIT_WHILE=1
  962.   fi
  963. done
  964. if [ "\$PROMPT_ANSWER" != "Y" ]; then
  965.   $ECHO_FOR_UNINSTALL
  966.   $ECHO_FOR_UNINSTALL "Uninstallation Aborted."
  967.   $ECHO_FOR_UNINSTALL
  968.   exit 1
  969. fi
  970. EOF
  971. if [ $? -ne 0 ]; then
  972.   $ECHO
  973.   $ECHO "$0: ERROR: following system command failed:"
  974.   $ECHO "\"cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  975.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  976.   $ECHO
  977.   cleanup 130
  978. fi
  979.  
  980. if [ "$UNINSTALL_LINE2" != "" ]; then
  981. cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  982. QUIT_WHILE=0
  983. while [ \$QUIT_WHILE -eq 0 ]
  984. do
  985.   $ECHO_FOR_UNINSTALL
  986.   $ECHO_FOR_UNINSTALL "Remove the CyberClassroom book directory with the system remove command(s):"
  987.   $ECHO_FOR_UNINSTALL "\\"$UNINSTALL_LINE2\\" ? (yes/no) [yes]: \c"
  988.   read YES_OR_NO
  989.   if [ "\$YES_OR_NO" = "" ]; then
  990.     YES_OR_NO="yes"
  991.   fi
  992.   PROMPT_ANSWER=\`$ECHO_FOR_UNINSTALL "\$YES_OR_NO" | tr "[:lower:]" "[:upper:]" | awk '{print substr(\$1,1,1)}'\`
  993.   if [ "\$PROMPT_ANSWER" != "Y" -a "\$PROMPT_ANSWER" != "N" ]; then
  994.     $ECHO_FOR_UNINSTALL 
  995.     $ECHO_FOR_UNINSTALL "Please answer with \\"yes\\" or \\"no\\".  Try again."
  996.   else
  997.     QUIT_WHILE=1
  998.   fi
  999. done
  1000. if [ "\$PROMPT_ANSWER" != "N" ]; then
  1001.   $ECHO_FOR_UNINSTALL
  1002.   $ECHO_FOR_UNINSTALL "$UNINSTALL_LINE2"
  1003.   $UNINSTALL_LINE2
  1004. fi
  1005. EOF
  1006. if [ $? -ne 0 ]; then
  1007.   $ECHO
  1008.   $ECHO "$0: ERROR: following system command failed:"
  1009.   $ECHO "\"cat << EOF > >$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1010.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1011.   $ECHO
  1012.   cleanup 135
  1013. fi
  1014. fi
  1015.  
  1016. if [ "$UNINSTALL_LINE3" != "" ]; then
  1017. cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  1018. QUIT_WHILE=0
  1019. while [ \$QUIT_WHILE -eq 0 ]
  1020. do
  1021.   $ECHO_FOR_UNINSTALL
  1022.   $ECHO_FOR_UNINSTALL "(WARNING: If you answer yes to the following question, previous CyberClassroom"
  1023.   $ECHO_FOR_UNINSTALL "products may no longer work !!!)"
  1024.   $ECHO_FOR_UNINSTALL
  1025.   $ECHO_FOR_UNINSTALL "Remove the CyberClassroom viewing engine directory with the system remove command:"
  1026.   $ECHO_FOR_UNINSTALL "\\"$UNINSTALL_LINE3\\" ? (yes/no) [yes]: \c"
  1027.   read YES_OR_NO
  1028.   if [ "\$YES_OR_NO" = "" ]; then
  1029.     YES_OR_NO="yes"
  1030.   fi
  1031.   PROMPT_ANSWER=\`$ECHO_FOR_UNINSTALL "\$YES_OR_NO" | tr "[:lower:]" "[:upper:]" | awk '{print substr(\$1,1,1)}'\`
  1032.   if [ "\$PROMPT_ANSWER" != "Y" -a "\$PROMPT_ANSWER" != "N" ]; then
  1033.     $ECHO_FOR_UNINSTALL 
  1034.     $ECHO_FOR_UNINSTALL "Please answer with \\"yes\\" or \\"no\\".  Try again."
  1035.   else
  1036.     QUIT_WHILE=1
  1037.   fi
  1038. done
  1039. if [ "\$PROMPT_ANSWER" != "N" ]; then
  1040.   $ECHO_FOR_UNINSTALL
  1041.   $ECHO_FOR_UNINSTALL "$UNINSTALL_LINE3"
  1042.   $UNINSTALL_LINE3
  1043. fi
  1044. EOF
  1045. if [ $? -ne 0 ]; then
  1046.   $ECHO
  1047.   $ECHO "$0: ERROR: following system command failed:"
  1048.   $ECHO "\"cat << EOF > >$CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1049.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1050.   $ECHO
  1051.   cleanup 140
  1052. fi
  1053. fi
  1054.  
  1055. if [ "$UNINSTALL_LINE4" != "" ]; then
  1056. cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  1057. QUIT_WHILE=0
  1058. while [ \$QUIT_WHILE -eq 0 ]
  1059. do
  1060.   $ECHO_FOR_UNINSTALL
  1061.   $ECHO_FOR_UNINSTALL "(WARNING: If you answer yes to the following question, previous CyberClassroom"
  1062.   $ECHO_FOR_UNINSTALL "products may also be removed !!!)"
  1063.   $ECHO_FOR_UNINSTALL
  1064.   $ECHO_FOR_UNINSTALL "Remove the entire CyberClassroom directory with system remove command:"
  1065.   $ECHO_FOR_UNINSTALL "\\"$UNINSTALL_LINE4\\" ? (yes/no) [no]: \c"
  1066.   read YES_OR_NO
  1067.   if [ "\$YES_OR_NO" = "" ]; then
  1068.     YES_OR_NO="no"
  1069.   fi
  1070.   PROMPT_ANSWER=\`$ECHO_FOR_UNINSTALL "\$YES_OR_NO" | tr "[:lower:]" "[:upper:]" | awk '{print substr(\$1,1,1)}'\`
  1071.   if [ "\$PROMPT_ANSWER" != "Y" -a "\$PROMPT_ANSWER" != "N" ]; then
  1072.     $ECHO_FOR_UNINSTALL 
  1073.     $ECHO_FOR_UNINSTALL "Please answer with \\"yes\\" or \\"no\\".  Try again."
  1074.   else
  1075.     QUIT_WHILE=1
  1076.   fi
  1077. done
  1078. if [ "\$PROMPT_ANSWER" != "N" ]; then
  1079.   $ECHO_FOR_UNINSTALL
  1080.   $ECHO_FOR_UNINSTALL "$UNINSTALL_LINE4"
  1081.   $UNINSTALL_LINE4
  1082. fi
  1083. EOF
  1084. if [ $? -ne 0 ]; then
  1085.   $ECHO
  1086.   $ECHO "$0: ERROR: following system command failed:"
  1087.   $ECHO "\"cat << EOF > $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1088.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1089.   $ECHO
  1090.   cleanup 145
  1091. fi
  1092. fi
  1093.  
  1094. # Add the uninstallation option to the uninstall script if
  1095. # this installation did infact install the JRE.
  1096. if [ "$UNINSTALL_LINE1" != "" ]; then
  1097. cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  1098. QUIT_WHILE=0
  1099. while [ \$QUIT_WHILE -eq 0 ]
  1100. do
  1101.   $ECHO_FOR_UNINSTALL
  1102.   $ECHO_FOR_UNINSTALL "(WARNING: If you answer yes to the following question, previous CyberClassroom"
  1103.   $ECHO_FOR_UNINSTALL "products may no longer execute properly !!!)"
  1104.   $ECHO_FOR_UNINSTALL
  1105.   $ECHO_FOR_UNINSTALL "Remove the entire JRE directory with system remove command"
  1106.   $ECHO_FOR_UNINSTALL "\\"$UNINSTALL_LINE1\\" ? (yes/no) [no]: \c"
  1107.   read YES_OR_NO
  1108.   if [ "\$YES_OR_NO" = "" ]; then
  1109.     YES_OR_NO="no"
  1110.   fi
  1111.   PROMPT_ANSWER=\`$ECHO_FOR_UNINSTALL "\$YES_OR_NO" | tr "[:lower:]" "[:upper:]" | awk '{print substr(\$1,1,1)}'\`
  1112.   if [ "\$PROMPT_ANSWER" != "Y" -a "\$PROMPT_ANSWER" != "N" ]; then
  1113.     $ECHO_FOR_UNINSTALL 
  1114.     $ECHO_FOR_UNINSTALL "Please answer with \\"yes\\" or \\"no\\".  Try again."
  1115.   else
  1116.     QUIT_WHILE=1
  1117.   fi
  1118. done
  1119. if [ "\$PROMPT_ANSWER" != "N" ]; then
  1120.   $ECHO_FOR_UNINSTALL
  1121.   $ECHO_FOR_UNINSTALL "$UNINSTALL_LINE1"
  1122.   $UNINSTALL_LINE1
  1123. fi
  1124. EOF
  1125. if [ $? -ne 0 ]; then
  1126.   $ECHO
  1127.   $ECHO "$0: ERROR: following system command failed:"
  1128.   $ECHO "\"cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1129.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1130.   $ECHO
  1131.   cleanup 150
  1132. fi
  1133. fi
  1134.  
  1135. # add an extra $ECHO line to the uninstall script
  1136. cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  1137. $ECHO_FOR_UNINSTALL
  1138. EOF
  1139. if [ $? -ne 0 ]; then
  1140.   $ECHO
  1141.   $ECHO "$0: ERROR: following system command failed:"
  1142.   $ECHO "\"cat << EOF >> $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1143.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1144.   $ECHO
  1145.   cleanup 155
  1146. fi
  1147.  
  1148. # make the uninstall script executable
  1149. chmod a+x $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT
  1150. if [ $? -ne 0 ]; then
  1151.   $ECHO
  1152.   $ECHO "$0: ERROR: following system command failed:"
  1153.   $ECHO "\"chmod a+x $CYBERCLASSROOM_LOCATION/$CYBERCLASSROOM_BOOK_DIR/$CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT\""
  1154.   $ECHO "Unable to create uninstallation script for the CyberClassroom book."
  1155.   $ECHO
  1156.   $ECHO "Installation Aborted, cleaning up..."
  1157.   $ECHO
  1158.   cleanup 160
  1159. fi
  1160.  
  1161. # Finalization screen
  1162.  
  1163. $ECHO
  1164. $ECHO "The Prentice Hall Perl Multimedia CyberClassroom has been sucessfully installed!"
  1165. $ECHO "Change your directory to \"$CYBERCLASSROOM_LOCATION\""
  1166. $ECHO "(cd $CYBERCLASSROOM_LOCATION) and execute the script"
  1167. $ECHO "\"$CYBERCLASSROOM_BOOK_SCRIPT\" (./$CYBERCLASSROOM_BOOK_SCRIPT) to run the program."
  1168. $ECHO
  1169.  
  1170.  
  1171.  
  1172.